package model;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class Category {
    private int id;
    private String name;
    private  boolean is_use=false;

    private String encodeName;

    public String getEncodeName() {
        return encodeName;
    }
    public void setEncodeName(String encodeName) {
        this.encodeName = encodeName;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public boolean isIs_use() {
        return is_use;
    }
    public void setIs_use(boolean is_use) {
        this.is_use = is_use;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
        try {
            this.encodeName = URLEncoder.encode(name, "utf-8");
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            //使用原始名称或抛出运行时的异常
            this.encodeName = name;
            //抛出更友好的异常
//            throw new IllegalArgumentException("不支持的编码格式",e);
//            e.printStackTrace();
        }
    }
    public Category() {
        super();
    }
    public Category(int id, String name, boolean is_use) {
        super();
        this.id = id;
        this.name = name;
        this.is_use = is_use;
    }

    public Category(String name, boolean use) {
        super();
        this.name = name;
        this.is_use=use;
    }
}

